package cn.edu.cug.cs.gtl.renders.openinventor.projectors;

import cn.edu.cug.cs.gtl.apis.render.basics.Line;
import cn.edu.cug.cs.gtl.apis.render.basics.Vec2f;
import cn.edu.cug.cs.gtl.apis.render.basics.Vec3f;
import cn.edu.cug.cs.gtl.apis.render.projectors.LineProjector;
import cn.edu.cug.cs.gtl.renders.openinventor.basics.LineImpl;
import cn.edu.cug.cs.gtl.renders.openinventor.basics.Vec3fImpl;
import com.openinventor.inventor.SbLine;
import com.openinventor.inventor.SbVec2f;
import com.openinventor.inventor.SbVec3f;
import com.openinventor.inventor.projectors.SbLineProjector;

public class LineProjectorImpl extends ProjectorImpl implements LineProjector {
    public LineProjectorImpl(SbLineProjector p) {
        super(p);
    }

    /**
     * Gets the line on which to project 2D points.
     *
     * @return
     */
    @Override
    public Line getLine() {
        return new LineImpl(((SbLineProjector)(this.nativeObject)).getLine());
    }

    /**
     * Gets a vector given the current mouse point.
     *
     * @param mousePosition
     * @return
     */
    @Override
    public Vec3f getVector(Vec2f mousePosition) {
        return new Vec3fImpl(((SbLineProjector)(this.nativeObject)).getVector((SbVec2f) mousePosition.getNativeObject()));
    }

    /**
     * Gets a vector on this line given two normalized mouse points.
     *
     * @param mousePosition1
     * @param mousePosition2
     * @return
     */
    @Override
    public Vec3f getVector(Vec2f mousePosition1, Vec2f mousePosition2) {
        return new Vec3fImpl(((SbLineProjector) (this.nativeObject)).getVector(
                (SbVec2f) mousePosition1.getNativeObject(),
                (SbVec2f) mousePosition2.getNativeObject()
        ));
    }

        /**
         * Sets the line on which to project 2D points.
         *
         * @param line
         */
    @Override
    public void setLine(Line line) {
        ((SbLineProjector)nativeObject).setLine((SbLine) line.getNativeObject());
    }

    /**
     * Sets the initial position from a mouse position.
     *
     * @param mousePosition
     */
    @Override
    public void setStartPosition(Vec2f mousePosition) {
        ((SbLineProjector)nativeObject).setStartPosition((SbVec2f) mousePosition.getNativeObject());
    }

    /**
     * Sets the initial position from a point on the projector.
     *
     * @param point
     */
    @Override
    public void setStartPosition(Vec3f point) {
        ((SbLineProjector)nativeObject).setStartPosition((SbVec3f) point.getNativeObject());
    }
}
